In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
The best selling vegetable in Byteland is logarithmic paprika. As the name of this great vegetable suggests, the weight of each paprika is the power of grams. The lightest paprika weighs grams, while the largest one weighs grams.
Residents of Byteland don't like buying pieces of paprika and so salesmen are forced to sell only whole paprika. What is more, bytean people are very exact and they do not tolerate situations when salesman is not able to sell the exact weight of paprika they are willing to buy. This causes stress among all salesmen of Byteland - some cases of insomnia have been observed as well. One of your friends, who owns vegetable garden, asked you to write a program which is supposed to help salesmen.
Write a program which:
The first line of the input contains one integer (), meaning that weights of available paprika are from the set . Second line contains positive integers not greater than , separated with single spaces and representing the current stock: paprika of weight gram, - of weight grams, ..., - of weight grams.
The first and only line of the output should contain one positive integer - the smallest weight that cannot be weighed without cutting any paprika.
For the input data:
2 2 1 1
the correct result is:
9
Example description: All weights from to can be weighed using paprika on the stock: , , , , , , , . Value can not be weighed, therefore it is the answer to the example.
Task author: Jakub Radoszewski.